package com.siki.config.filterConfig.jwtConfig;

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.siki.pojo.commonEntity.SysUser;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * 生成token
 *
 * @Author Siki
 * @Date 2020/6/5
 */
@Service("TokenFactory")
public class TokenFactory {

    public String getToken(SysUser sysuser) {
        String token="";
        token= JWT.create().withAudience(sysuser.getId()).withIssuedAt(new Date())
                .sign(Algorithm.HMAC256(sysuser.getPassword()));
        return token;
    }
}
